﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucConfig.ascx.cs" Inherits="SES.CMS.AdminCP.PageUC.ucConfig" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function OnClientPasteHtml(sender, args) {
            var commandName = args.get_commandName();
            var value = args.get_value();
            if (commandName == "ImageManager") {
                //See if an img has an alt tag set
                var div = document.createElement("DIV");
                //Do not use div.innerHTML as in IE this would cause the image's src or the link's href to be converted to absolute path.
                //This is a severe IE quirk.
                Telerik.Web.UI.Editor.Utils.setElementInnerHtml(div, value);
                //Now check if there is alt attribute
                var img = div.firstChild;
                //alert(div.innerHTML);

                //Set new content to be pasted into the editor

                if (!!img.alt) {
                    var newInner = "<center>";
                    newInner = newInner + "<img src='" + img.src + "' alt='" + img.alt + "'/></center><center>";
                    newInner = newInner + img.alt + "</center>";

                    args.set_value(newInner);
                }
                else {
                    var newInner = "<center><img src='" + img.src + "' alt='Dang Viet jsc'/></center><br/>";

                    args.set_value(newInner);
                }

            }
        }
    </script>
</telerik:RadCodeBlock>
<h2>
    Cập nhật Cấu hình</h2>
<table width="100%" border="1">
    <tr>
        <td class="style8" style="width:150px;">
            Tiêu đề:
        </td>
        <td class="style9">
            <asp:TextBox ID="txtTitle" runat="server" Width="379px" ValidationGroup="submitGrp"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle"
                ErrorMessage="*** Cần nhập tiêu đề" ValidationGroup="submitGrp"></asp:RequiredFieldValidator>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:CheckBox ID="chkActive" runat="server" Checked="True" Text="Active" />
        </td>
    </tr>
    <tr id="trDes" runat="server" visible="false">
        <td class="style8">
            Chi tiết:
        </td>
        <td>
            <asp:TextBox ID="txtDescription" TextMode="MultiLine" runat="server" Width="90%">
            </asp:TextBox>
        </td>
    </tr>
    <tr id="trSupport" runat="server" visible="false">
        <td class="style8">
            Trình bày:
        </td>
        <td>
            <CKEditor:CKEditorControl ID="txtCK" runat="server" Width="90%" Visible="false">
            </CKEditor:CKEditorControl>
            <telerik:RadEditor ID="txtCKX" runat="server" OnClientPasteHtml="OnClientPasteHtml"
                DialogHandlerUrl="~/Telerik.Web.UI.DialogHandler.axd" Width="99%" Height="700px">
                <ImageManager MaxUploadFileSize="1024000000" ViewMode="Grid" DeletePaths="~/Media/"
                    UploadPaths="~/Media/" ViewPaths="~/Media/"></ImageManager>
            </telerik:RadEditor>
        </td>
    </tr>
    <tr runat="server" id="trPopup" visible="false">
        <td class="style8">
            Hình ảnh
        </td>
        <td class="style9">
            <asp:FileUpload ID="fuImage" runat="server" />
            &nbsp;
            <asp:HyperLink ID="hplImage" runat="server" Target="_blank">[Xem 
            ảnh]</asp:HyperLink>
        </td>
    </tr>
    <tr>
        <td class="style8">
            &nbsp;
        </td>
        <td class="style4">
            <asp:Button ID="btnSave" runat="server" Text="Lưu" OnClick="btnSave_Click" ValidationGroup="submitGrp" />
            <asp:Button ID="btnReset" runat="server" Text="Hủy" />
        </td>
    </tr>
</table>
